/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nivelacesso.classes;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Wolverine
 */
public class NivelTableModel extends AbstractTableModel{

   private List<Nivel> listaNivel;
   private String[] colunas ={"Id Nível", "Descrição"};

    public NivelTableModel(List<Nivel> listaNivel) {
        this.listaNivel = listaNivel;
    }

    public List<Nivel> getListaNivel() {
        return listaNivel;
    }

    public void setListaNivel(List<Nivel> listaNivel) {
        this.listaNivel = listaNivel;
    }



    public int getRowCount() {
        return listaNivel.size();
    }

    public int getColumnCount() {
        return colunas.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
         Nivel nivel = listaNivel.get(rowIndex);
         if (columnIndex==0){
             return nivel.getIdnivel();
         }else return  nivel.getDescricao();
    }

    public  void adicionar(Nivel nivel){
        listaNivel.add(nivel);
    }

    public void adicionar(List<Nivel> nivel){
        listaNivel.addAll(nivel);
    }

    @Override
    public String getColumnName(int column) {
        return colunas[column];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        if (columnIndex==0){
             return Integer.class;
         }else return  String.class;
    }

    public Nivel getNivel(int linha){
        return  listaNivel.get(linha);
    }


}
